from page.mainpage import MainPage


class CountyManagement(MainPage):

    def locate_addcounty_button(self):
        """
        定位新增县级按钮
        :return:
        """
        self.locate("css","div.options > div.actionsgroup > button:nth-child(3)")

    def add_county(self, username, pwd):
        """
        点击新增县级
        打开县级名称选择下拉框
        选择列表第一个区县
        输入账号
        输入密码
        点击提交
        :param username:县级名称
        :param pwd: 密码
        :return:
        """
        self.click("css", "div.options > div.actionsgroup > button:nth-child(3)")
        self.click("css", 'div.main-content > section > section > div:nth-child(2) > div > div > input')
        self.click("css",
                   'body > div.el-select-dropdown.el-popper > div.el-scrollbar > div.el-select-dropdown__wrap.el-scrollbar__wrap > ul > li:nth-child(1)')
        self.send_keys("css", 'div.main-content > section > section > div:nth-child(3) > div > input', username)
        self.send_keys("css", 'div.main-content > section > section > div:nth-child(4) > div > input', pwd)
        self.click_submit()

    def get_num1_countyname(self):
        """

        :return:获取县级列表排在第一个的县级名称
        """
        return self.get_text("css", "div.el-table__body-wrapper.is-scrolling-none > table > tbody > tr:nth-child(1) > td.el-table_1_column_1.is-center")

    def get_num1_countyaccount(self):
        """

        :return:获取排在县级列表第一个的县级账号
        """
        return self.get_text("css", "div.el-table__body-wrapper.is-scrolling-none > table > tbody > tr:nth-child(1) > td.el-table_1_column_2.is-center")

    def edit_county(self, pwd):
        """
        点击编辑列表第一个县级
        打开县级名称选择下拉框
        选择第一个区县
        输入密码
        点击提交
        :param pwd:密码
        :return:
        """
        self.click("css",
                   "div.el-table__fixed-body-wrapper > table > tbody > tr > td.el-table_1_column_6.is-center > div > button:nth-child(1)")
        self.click("css", 'div.main-content > section > section > div:nth-child(2) > div > div > input')
        self.click("css",
                   'body > div.el-select-dropdown.el-popper > div.el-scrollbar > div.el-select-dropdown__wrap.el-scrollbar__wrap > ul > li:nth-child(1)')
        self.send_keys("css", 'div.main-content > section > section > div:nth-child(4) > div > input', pwd)
        self.click_submit()

    def delete_num1_county(self):
        """
        点击删除列表第一个县级
        :return:
        """
        self.click("css",
                   "div.el-table__fixed-body-wrapper > table > tbody > tr:nth-child(1) > td.el-table_1_column_6.is-center > div > button:nth-child(2)")

    def goto_num1_countydetails(self):
        """
        点击进入第一个县级详情
        :return:
        """
        self.click("css",
                   "div.el-table__fixed-body-wrapper > table > tbody > tr > td.el-table_1_column_6.is-center > div > button:nth-child(3)")

    def get_addschool_text(self):
        """

        :return:获取新增学校按钮文本
        """
        return self.get_text("css", "div.options > div.actionsgroup > button:nth-child(3)")
